package qdu.edu.com.fushanf4.service.count.usertype.search2characters.count.clean;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;
import qdu.edu.com.fushanf4.utils.UtilConstants;

import java.io.IOException;

public class CleanStringMapper extends Mapper<LongWritable, Text, NullWritable, Text> {
    private final Text valueOut = new Text();

    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
        String line = value.toString();
        String[] lines = line.split(UtilConstants.RegexOfString.EXCEPT_CHINESE_CHARACTERS);
        for (String aLine : lines) {
            if (!aLine.equals("")) {
                valueOut.set(aLine);
                context.write(NullWritable.get(), valueOut);
            }
        }
    }
}
